function [ex,exnobar,st] = extrsubf( outpath , rootpath )
% ===============================================================
% EXTRSUBF.m
%
% function [ex,exnobar,st] = extrsubf( outpath , rootpath )
%
% Extract SUBINDEX from a rootpath 
% e.g. if ROOTPATH = C:\A\B 
% and OUTPATH is C:\A\B\out 
% EX: extracted string is out and 
% STl starting position is 7 
% 
% If not nested then string is rootpath and starting position is []  
% 
% Alejandro Justiniano 9/7/2005 
% ==================================================================
n1 = length( rootpath ); 
n2 = length( outpath  ); 
if n2 < n1;
    ind = 0;
else
    ind = strncmp( outpath , rootpath , n1 );
end

if ind == 0 
    ex = outpath ; 
    st = []; 
else 
    ex = outpath( n1+1:end ); 
    st = n1; 
end 
exnobar=ex; 
temp=findstr(exnobar,'\'); 
if ~isempty(temp); exnobar(temp)=' '; end; 
temp=findstr(exnobar,'/'); 
if ~isempty(temp); exnobar(temp)=' '; end; 
exnobar=exnobar(2:end); 
    